package com.cpit.platform.config;

import com.cpit.platform.common.utils.Encodes;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.stereotype.Component;

@Component
@ConfigurationProperties(prefix = "upload")
public class UploadPathConfig {

    @Autowired
    private GlobalConfig globalConfig;

    private String path = "./upload";

    private String temp = "./upload/temp";

    private String unqualified = "./upload/unqualified";

    private String apk = "./upload/apk";


    /**
     * 生成download64 文件下载咱径
     *
     * @param filePath
     * @return
     */
    public String getWebDownloadBase64Path(String filePath) {
        StringBuilder sb = new StringBuilder(globalConfig.getContextPath() +"/file/download64/");
        sb.append(Encodes.encodeBase64(filePath));

        return sb.toString();
    }

    /**
     * 生成delete64 文件删除路径
     *
     * @param filePath
     * @return
     */
    public String getWebDeleteBase64Path(String filePath) {
        StringBuilder sb = new StringBuilder("/file/delete64/");
        sb.append(Encodes.encodeBase64(filePath));

        return sb.toString();
    }

    public String getPath() {
        return path;
    }

    public void setPath(String path) {
        this.path = path;
    }

    public String getTemp() {
        return temp;
    }

    public void setTemp(String temp) {
        this.temp = temp;
    }

    public String getUnqualified() {
        return unqualified;
    }

    public void setUnqualified(String unqualified) {
        this.unqualified = unqualified;
    }

    public String getApk() {
        return apk;
    }

    public void setApk(String apk) {
        this.apk = apk;
    }

}
